#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>

void bubble_sort(int arr[], int sz)
{
    int i = 0;
    for (i = 0; i < sz - 1; i++)
    {
        int j = 0;
        for (j = 0; j < sz - 1 - i; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                int tmp = 0;
                tmp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = tmp;
            }
        }
    }
}

int main()
{
    int arr[3] = { 0 };
    int i = 0;
    for (i = 0; i < 3; i++)
        scanf("%d", &arr[i]);
    getchar();
    int sz = sizeof(arr) / sizeof(arr[0]);
    bubble_sort(arr, sz);
    char ans[4];
    scanf("%s", ans);
    for (i = 0; i < 3; i++)
    {
        switch (ans[i])
        {
        case 'A':
            printf("%d ", arr[0]);
            break;
        case 'B':
            printf("%d ", arr[1]);
            break;
        case 'C':
            printf("%d ", arr[2]);
            break;
        }
    }
    return 0;
}